from PyQt5.QtWidgets import QApplication,QWidget,QLabel,QLineEdit,QTextEdit,QVBoxLayout,QRadioButton
from PyQt5.QtWidgets import QPushButton,QHBoxLayout,QFormLayout,QMessageBox,QInputDialog,QColorDialog
from PyQt5.QtWidgets import QButtonGroup,QCheckBox
from PyQt5.QtGui import QIcon,QPixmap
import sys
def start():
    print("喝酒",btn1.isChecked())
def btn_start(flag,text,arg:QCheckBox):
    print(f"{flag}:{text} -> {arg}")
def  on_smmit():
    print("抽烟",btn.isChecked())
    print("喝酒",btn1.isChecked())
    print("烫头",btn2.isChecked())
    
if __name__ == "__main__":
    # 创建QApplication对象
    app=QApplication(sys.argv)
    #创建窗口
    window=QWidget()
    #命名窗口
    window.setWindowTitle("对话框")
    #指定图标
    window.setWindowIcon(QIcon("gege.png"))
    #设置窗口大小
    window.resize(1000, 800)
    #——————————————————————————————————————组件初始化
    root_layout = QVBoxLayout(window)
    btn=QCheckBox("抽烟")
    btn1=QCheckBox("喝酒")
    btn2=QCheckBox("烫头")
    btn2.setChecked(True)
    btn.stateChanged.connect(lambda arg:btn_start(0,"抽烟",arg))
    btn1.stateChanged.connect(lambda arg:btn_start(1,"喝酒",arg))
    btn2.stateChanged.connect(lambda arg:btn_start(2,"烫头",arg))
    
    root_layout.addWidget(QLabel("于谦的三大爱好"))
    root_layout.addWidget(btn)
    root_layout.addWidget(btn1)
    root_layout.addWidget(btn2)
    
    btn_submit=QPushButton("提交")
    btn_submit.clicked.connect(on_smmit)
    root_layout.addWidget(btn_submit)
  
    # window.setLayout(root_layout)

    #_____________________________________
    #显示窗口
    window.show()
    #鼠标悬浮文字
    window.setToolTip("你好")
    #结束
    sys.exit(app.exec_())
    
    
    
    
    